5
תגובות
יש לי קוד כזה
[code]
require_once('config.php');
//
$link = mysql_connect($config['mysql']['host'], $config['mysql']['username'], $config['mysql']['password']);
mysql_select_db($config['mysql']['db_name']);
mysql_query("set names utf8");
$oldUrl = str_replace("qstring=", "", $_SERVER["QUERY_STRING"]);
$oldUrl = str_replace("&", "&", $oldUrl);
echo $oldUrl;
die();
$oldUrl=html_entity_decode(str_replace ($new_Line , ' ' ,$oldUrl));
$q = mysql_query("SELECT new_url FROM mod_301 WHERE old_url = '".$oldUrl."' ");
if($res = mysql_fetch_assoc($q))
{
header('Location: ' .str_replace("&", "&", $res['new_url']) );
}
else
{
$oldUrl = preg_replace("/&/", "?", $oldUrl, 1);
$q22 = mysql_query("SELECT new_url FROM mod_301 WHERE old_url = '".$oldUrl."' ");
$res22 = mysql_fetch_assoc($q22);
header('Location: ' .str_replace("&", "&", $res22['new_url']) );
}
[/code]
יש לי כתובת בעברית
Articals.asp?id=40&title=חופשה בים המלח
או מציג לי
Articals.asp?id=40&title=%25D7%2597%25D7%2595%25D7%25A4%25D7%25A9%25D7%2594%2520%25D7%2591%25D7%2599%
25D7%259D%2520%25D7%2594%25D7%259E%25D7%259C%25D7%2597
ואז אני בודק בdb ואין שורה כזאת יש שורה כמו ראשונה -
איך לפתור את זה
[code]
require_once('config.php');
//
$link = mysql_connect($config['mysql']['host'], $config['mysql']['username'], $config['mysql']['password']);
mysql_select_db($config['mysql']['db_name']);
mysql_query("set names utf8");
$oldUrl = str_replace("qstring=", "", $_SERVER["QUERY_STRING"]);
$oldUrl = str_replace("&", "&", $oldUrl);
echo $oldUrl;
die();
$oldUrl=html_entity_decode(str_replace ($new_Line , ' ' ,$oldUrl));
$q = mysql_query("SELECT new_url FROM mod_301 WHERE old_url = '".$oldUrl."' ");
if($res = mysql_fetch_assoc($q))
{
header('Location: ' .str_replace("&", "&", $res['new_url']) );
}
else
{
$oldUrl = preg_replace("/&/", "?", $oldUrl, 1);
$q22 = mysql_query("SELECT new_url FROM mod_301 WHERE old_url = '".$oldUrl."' ");
$res22 = mysql_fetch_assoc($q22);
header('Location: ' .str_replace("&", "&", $res22['new_url']) );
}
[/code]
יש לי כתובת בעברית
Articals.asp?id=40&title=חופשה בים המלח
או מציג לי
Articals.asp?id=40&title=%25D7%2597%25D7%2595%25D7%25A4%25D7%25A9%25D7%2594%2520%25D7%2591%25D7%2599%
25D7%259D%2520%25D7%2594%25D7%259E%25D7%259C%25D7%2597
ואז אני בודק בdb ואין שורה כזאת יש שורה כמו ראשונה -
איך לפתור את זה
5 תשובות
require_once('config.php');
//
$link = mysql_connect($config['mysql']['host'], $config['mysql']['username'], $config['mysql']['password']);
mysql_select_db($config['mysql']['db_name']);
mysql_query("set names utf8");
$oldUrl = str_replace("qstring=", "", $_SERVER["QUERY_STRING"]);
$oldUrl = str_replace("&", "&", $oldUrl);
echo $oldUrl;
die();
$oldUrl=html_entity_decode(str_replace ($new_Line , ' ' ,$oldUrl));
$q = mysql_query("SELECT new_url FROM mod_301 WHERE old_url = '".$oldUrl."' ");
if($res = mysql_fetch_assoc($q))
{
header('Location: ' .str_replace("&", "&", $res['new_url']) );
}
else
{
$oldUrl = preg_replace("/&/", "?", $oldUrl, 1);
$q22 = mysql_query("SELECT new_url FROM mod_301 WHERE old_url = '".$oldUrl."' ");
$res22 = mysql_fetch_assoc($q22);
header('Location: ' .str_replace("&", "&", $res22['new_url']) );
}
//
$link = mysql_connect($config['mysql']['host'], $config['mysql']['username'], $config['mysql']['password']);
mysql_select_db($config['mysql']['db_name']);
mysql_query("set names utf8");
$oldUrl = str_replace("qstring=", "", $_SERVER["QUERY_STRING"]);
$oldUrl = str_replace("&", "&", $oldUrl);
echo $oldUrl;
die();
$oldUrl=html_entity_decode(str_replace ($new_Line , ' ' ,$oldUrl));
$q = mysql_query("SELECT new_url FROM mod_301 WHERE old_url = '".$oldUrl."' ");
if($res = mysql_fetch_assoc($q))
{
header('Location: ' .str_replace("&", "&", $res['new_url']) );
}
else
{
$oldUrl = preg_replace("/&/", "?", $oldUrl, 1);
$q22 = mysql_query("SELECT new_url FROM mod_301 WHERE old_url = '".$oldUrl."' ");
$res22 = mysql_fetch_assoc($q22);
header('Location: ' .str_replace("&", "&", $res22['new_url']) );
}
למה אתה עובד לפי url ולא לפי id או title?
ולמה str_replace יש לך פונקציות מובנות לעבוד עם urls..